<template>
  <div class="login">
    <el-row class="loginCenter" style="z-index: 1;">
      <el-col :model="user">
        <el-card
          class="login-box"
          v-loading="$store.state.loading"
          element-loading-background="rgba(0, 0, 0, 0.8)"
        >
          <el-form @keyup.enter.native="login">
            <h1 class="title">欢迎使用PC官网管理后台</h1>
            <p class="login-box-msg">疾如风，徐如林!</p>
            <el-form-item>
              <el-input
                type="text"
                v-model="user.loginName"
                auto-complete="off"
                placeholder="请输入用户名..."
                suffix-icon="el-icon-bell"
              ></el-input>
            </el-form-item>
            <el-form-item>
              <el-input
                type="password"
                v-model="user.password"
                auto-complete="off"
                placeholder="请输入密码..."
                suffix-icon="el-icon-edit"
              ></el-input>
            </el-form-item>
            <el-form-item>
              <el-button
                type="primary"
                @click="login"
                :loading="$store.state.loading"
                class="pull-right"
                style="width:100%"
                >登录</el-button
              >
            </el-form-item>
          </el-form>
        </el-card>
      </el-col>
    </el-row>
  </div>
</template>
<script>
export default {
  name: "Login",
  data() {
    return {
      user: {
        loginName: "admin",
        password: "",
      },
    };
  },
  methods: {
    login() {
      this.$axios
        .post("/api/users/login.json?plat=web", this.user)
        .then((response) => {
          this.$message.success("登录成功");
          this.$store.commit("setToken", response.token);
          this.$store.commit("setUser", response.user);
          this.$router.push("/advertisementManage");
        });
    },
  },
};
</script>

<style>
.login {
  background: url(../assets/bg.png) no-repeat scroll center center / cover;
  background-size: 100% 100%;
  width: 100%;
  height: 100%;
  position: fixed;
  display: flex;
  justify-content: center;
  align-items: center;
}
.loginCenter {
  /* width: 300px;
  height: 300px; */
}

.login-box {
  background: #ffffff;
  border: none;
}

.login-box-msg {
  color: #000000;
  text-align: center;
}

.login-box .title {
  color: #000000;
  text-align: center;
}
</style>
